import { useAdminStore } from '@/store';

/**
 * 检查权限
 * @param {Array} value
 * @returns {Boolean}
 */
export default function checkPermission(value) {
  if (value && value instanceof Array && value.length > 0) {
    const adminStore = useAdminStore();
    const roleRoutes = adminStore.role_routes;
    const permissionRoles = value;
    const hasPermission = roleRoutes.some(roleroute => {
      return permissionRoles.includes(roleroute);
    });
    return hasPermission;
  }
  return false;
}